package qeug.shsh.fi.flowPlugin;

import cn.hutool.core.date.DateUtil;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.workflow.api.AgentExecution;
import kd.bos.workflow.engine.extitf.IWorkflowPlugin;
import org.json.XML;
import qeug.shsh.bpm.Factory.ThirdServiceFactory;
import qeug.shsh.bpm.service.IG6Service;
import qeug.shsh.helper.FacadeHelper;
import qeug.shsh.webService.WebServiceUtil;

import javax.xml.rpc.ServiceException;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.Date;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

public class TravelReimburflowPlugin implements IWorkflowPlugin {

    @Override
    public void notify(AgentExecution execution) {
        try {
            IWorkflowPlugin.super.notify(execution);
            String fid = execution.getBusinessKey();//单据id
            String entityNumber = execution.getEntityNumber();//单据标识
            DynamicObject bill = BusinessDataServiceHelper.loadSingle(fid, entityNumber);
            if (bill != null) {
                switch (entityNumber){
                    //差旅报销
                    case "er_tripreimburse":
                        IG6Service g6Service = ThirdServiceFactory.createG6Service();
                        g6Service.payForTravel(bill);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
